-- THESE SCRIPTS ARE COPYRIGHTED BY MAC HELP COMPANY
-- CONTACT AUTHOR FOR PERMISSION TO USE THESE SCRIPTS
end copyright
on mouseUp
set numberformat to 0.00
if the optionKey is down then
put "You can analyize your sub accounts and your Income Database" && "entries. It takes a while, but the information is very useful." && "The table shows your daily transactions, as well as summaries" && "for each sub account for the month, quarter and year. Also" && "a summary of all the accounts (by month) is generated at the" && "end." into String
put the name of the target into ThisItem
HelpMsg1 String, ThisItem
exit mouseUp
end if
answer "Generate an updated report of your sub Account activity?" & " " & "                                      " & "(This will definitely take quite a bit of time.)" with "Cancel" or "Yes"
if it is "Cancel" then exit mouseUp
put 1 into AnalyizeFrom
put 2 into AnalyizeTo
answer "Do you wish to make an analysis of the 'Account Activity' "& "or of the 'DataBase' activity?" with "Account" or "DataBase" or "Both"
if it is "Account" then put 1 into AnalyizeTo
if it is "DataBase" then put 2 into AnalyizeFrom
answer "Sort Cards before making a report?" with "Yes" or "No"
if it is "Yes" then
set lockscreen to true
sort by background field "Sub Title"
end if
answer "Do the transactions on the sub account cards need to be " & "re-sorted so that they will appear in order by date?" with "Yes" or "No"
if it is "Yes" then
put true into sortItems
else
put false into sortItems
end if
go to card "Rpt."
set lockscreen to false
put "Updating..." into card field "Wait Pop"
show card field "Wait Pop"
set lockscreen to true
set cursor to 4
hide card field "Wait Pop"
put empty into background field "Rpt." of card "Rpt."
put 0 into lineNum
repeat with AcctAnalysis = AnalyizeFrom to AnalyizeTo
if AcctAnalysis is 1 then
put "Sub Amount" into AnalysisField
else
put "Sub Amount2" into AnalysisField
end if
go to card 1 of background "Sub Accounts"
put the ID of this card into ReturnID
put empty into card field MonthSums of card "Rpt."
repeat with i = 1 to 12
put "0 0" into line i of card field "MonthSums" of card "Rpt."
end repeat
put 0 into AllMonth
put 0 into AllQuarter
put 0 into AllYear
repeat forever -- go through every sub card
put 0 into Daily
put 0 into Weekly
put 0 into Monthly
put 0 into Quarterly
put 0 into Yearly
put 0 into RunningTotal
put 0 into LastDate
put 0 into LastQuarter
put 0 into LastAmount
put runningTotal into LastTotal
put background field "Sub Title" into SubName
if AcctAnalysis is 1 then
put SubName & " ( $" & background field "Sub Total" & " )" into SubName
else
put SubName & " ( $" & background field "Sub Total2" & " )" into SubName
end if
put 0 into i
put SubName into line LineNum of background field "Rpt." of card "Rpt."
add 1 to LineNum
repeat forever -- go through every trans for this sub
add 1 to i
get line i of background field AnalysisField
put word 1 of it into ThisDate
put ThisDate into realDate
convert ThisDate to DateItems
put word 3 of it into Amount
put word 4 of it into SubTrans
-- each line
add 1 to LineNum
put " " into line LineNum of background field "Rpt." of card "Rpt."
put RealDate into char (10-length(RealDate)) of line LineNum of background field "Rpt." of card "Rpt."
put SubTrans into char 12 of line LineNum of background field "Rpt." of card "Rpt."
put Amount into char (27-length(Amount)) of line LineNum of background field "Rpt." of card "Rpt."
-- running Total
add amount to RunningTotal
-- do daily
if ThisDate is LastDate then
add LastAmount to daily
else
-- put the daily before clearing
if the value of Daily is not 0 then
add LastAmount to daily
subtract 1 from LineNum
put Daily into char (40-length(Daily)) of line LineNum of background field "Rpt." of card "Rpt."
add 1 to LineNum
end if
put 0 into daily
end if
-- do weekly
-- do monthly
put item 2 of ThisDate into Temp1
put item 2 of LastDate into Temp2
if Temp1 > 0 and Amount is not empty then
if Amount > 0 then -- this is income
add Amount to word 1 of line Temp1 of card field MonthSums of card "Rpt."
else
add Amount to word 2 of line Temp1 of card field MonthSums of card "Rpt."
end if
end if
if (Temp1 is not Temp2) and LastDate is not 0 then
-- put the monthly before clearing
if the value of monthly is not 0 then
Subtract 1 from LineNum
put Monthly into char (53-length(Monthly)) of line LineNum of background field "Rpt." of card "Rpt."
add 1 to LineNum
add Monthly to AllMonth
end if
put 0 into Monthly
end if
-- do quarterly
put 4 into Quarter
if item 2 of ThisDate < 10 then put 3 into Quarter
if item 2 of ThisDate < 7 then put 2 into Quarter
if item 2 of ThisDate < 4 then put 1 into Quarter
if (Quarter is not LastQuarter) and LastQuarter is not 0 then
-- put the quarterly before clearing
if the value of Quarterly is not 0 then
subtract 1 from LineNum
put Quarterly into char (65-length(Quarterly)) of line LineNum of background field "Rpt." of card "Rpt."
add 1 to LineNum
add Quarterly to AllQuarter
end if
put 0 into quarterly
end if
-- do yearly
put item 1 of ThisDate into Temp1
put item 1 of LastDate into Temp2
if (Temp1 is not Temp2) and LastDate is not 0 then
-- put the yearly before clearing
if the value of Yearly is not 0 then
subtract 1 from LineNum
put Yearly into char (80-length(Yearly)) of line LineNum of background field "Rpt." of card "Rpt."
add 1 to LineNum
add Yearly to AllYear
end if
put 0 into yearly
end if
put ThisDate into LastDate
put Quarter into LastQuarter
put Amount into LastAmount
add Amount to Monthly
add Amount to quarterly
add Amount to yearly
--ask "Last total for " && SubName && realDate with runningTotal --**
get line i of background field AnalysisField
if it is empty then exit repeat
end repeat
go to next card of this background
if the ID of this Card is ReturnID then exit repeat
if sortItems then -- sort each line of sub acct trans. by date
put the number of lines of background field AnalysisField into TotLines
put 0 into h
repeat forever
add 1 to h
if h > TotLines or h = TotLines then exit repeat
put word 1 of line h of background field AnalysisField into temp1
put line h of background field AnalysisField into BeforeLine
put word 1 of line h+1 of background field AnalysisField into temp2
put line h+1 of background field AnalysisField into AfterLine
convert temp1 to seconds
convert temp2 to seconds
if AfterLine is empty then
delete line h+1 of background field AnalysisField
else
if temp1 > Temp2 then
put BeforeLine into line h+1 of background field AnalysisField
put AfterLine into line h of background field AnalysisField
put 0 into h
end if
end if
end repeat
end if
add 1 to LineNum
put " " into line LineNum of background field "Rpt." of card "Rpt."
add 1 to LineNum
put " " into line LineNum of background field "Rpt." of card "Rpt."
add 1 to LineNum
put " " into line LineNum of background field "Rpt." of card "Rpt."
--exit repeat -- for one card only
end repeat
add 1 to LineNum
put " " into line LineNum of background field "Rpt." of card "Rpt."
add 1 to lineNum
put " " into line LineNum of background field "Rpt." of card "Rpt."
put "----------" into char 70 of line LineNum of background field "Rpt." of card "Rpt."
add 1 to lineNum
put " " into line LineNum of background field "Rpt." of card "Rpt."
put AllYear into char (80-length(AllYear)) of line LineNum of background field "Rpt." of card "Rpt."
-- put totals for each month
add 1 to LineNum
put " " into line LineNum of background field "Rpt." of card "Rpt."
add 1 to LineNum
put " " into line LineNum of background field "Rpt." of card "Rpt."
add 1 to LineNum
put " " into line LineNum of background field "Rpt." of card "Rpt."
add 1 to LineNum
put " " into line LineNum of background field "Rpt." of card "Rpt."
put "MONTH" into char (15-length("Month")) of line LineNum of background field "Rpt." of card "Rpt."
put "INCOME" into char (30-length("Income")) of line LineNum of background field "Rpt." of card "Rpt."
put "EXPENSE" into char (50-length("Expense")) of line LineNum of background field "Rpt." of card "Rpt."
put "BALANCE" into char (70-length("Balance")) of line LineNum of background field "Rpt." of card "Rpt."
add 1 to LineNum
put " ------------------------------------------------------------------------" into line LineNum of background field "Rpt." of card "Rpt."
repeat with j = 1 to 12
get line j of card field "MonthSums" of card "Rpt."
put the value of word 1 of it into Inc
put the value of word 2 of it into Exp
put Inc + Exp into Bal
if j is 1 then put "January" into MName
if j is 2 then put "February" into MName
if j is 3 then put "March" into MName
if j is 4 then put "April" into MName
if j is 5 then put "May" into MName
if j is 6 then put "June" into MName
if j is 7 then put "July" into MName
if j is 8 then put "August" into MName
if j is 9 then put "September" into MName
if j is 10 then put "October" into MName
if j is 11 then put "November" into MName
if j is 12 then put "December" into MName
add 1 to LineNum
put " " into line LineNum of background field "Rpt." of card "Rpt."
put MName into char (15-length(MName)) of line LineNum of background field "Rpt." of card "Rpt."
put Inc into char (30-length(Inc)) of line LineNum of background field "Rpt." of card "Rpt."
put Exp into char (50-length(Exp)) of line LineNum of background field "Rpt." of card "Rpt."
put bal into char (70-length(bal)) of line LineNum of background field "Rpt." of card "Rpt."
end repeat
add 1 to LineNum
put " " into line LineNum of background field "Rpt." of card "Rpt."
add 1 to LineNum
put " " into line LineNum of background field "Rpt." of card "Rpt."
add 1 to LineNum
put " " into line LineNum of background field "Rpt." of card "Rpt."
go to card "Rpt."
end repeat
set lockscreen to false
play boing a
play boing a
end mouseUp
-- part 9 (field)
-- low flags: 81
-- high flags: 2004
-- rect: left=41 top=189 right=264 bottom=460
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 204
-- text size: 48
-- style flags: 6912
-- line height: 64
-- part name: Wait Pop
-- part 12 (field)
-- low flags: 80
-- high flags: 0007
-- rect: left=2 top=39 right=294 bottom=511
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 4
-- text size: 9
-- style flags: 0
-- line height: 11
-- part name: MonthSums
-- part 13 (button)
-- low flags: 00
-- high flags: A004
-- rect: left=162 top=289 right=338 bottom=219
-- title width / last selected line: 0
-- icon id / first selected line: 1007 / 1007
-- text alignment: 1
-- font id: 0
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: Print
----- HyperTalk script -----
on mouseUp
set lockscreen to true
doMenu "Page Setup..."
set Lockscreen to True
doMenu "Print Report..."
set lockscreen to false
end mouseUp
-- part 14 (field)
-- low flags: 00
-- high flags: 0007
-- rect: left=2 top=33 right=287 bottom=511
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 4
-- text size: 9
-- style flags: 0
-- line height: 11
-- part name: Rpt.
-- part 15 (button)
-- low flags: 00
-- high flags: A004
-- rect: left=102 top=289 right=338 bottom=158
-- title width / last selected line: 0
-- icon id / first selected line: 12195 / 12195
-- text alignment: 1
-- font id: 0
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: Text File
----- HyperTalk script -----
on mouseUp
if the optionKey is down then
put "You can write the information generated by the analysis to" && "a text file. You could then use a different program such as" && "a word processor to import that file. (Tabs are automatically" && "set between columns, for better formatting.)" into String
put the name of the target into ThisItem
HelpMsg1 String, ThisItem
exit mouseUp
end if
ask "Before saving, name the file you want to save this data to?" with "(Ckg/Savings) Sub Acct Analysis"
put it into ThisFile
if ThisFile is empty then exit mouseUp
open File ThisFile
write "For better format, set your tabs to separate each column "& "of this listing!" & Return & Return to file ThisFile
set cursor to 4
set lockscreen to true
write tab & card field "Rpt. Title" to file ThisFile
put the number of lines of background field "Rpt." into TotalLines
repeat with i = 1 to TotalLines
put the number of words of line i of background field "Rpt." into TotalWords
put empty into stuff
repeat with j = 1 to TotalWords
put stuff & tab & word j of line i of background field "Rpt." into stuff
end repeat
write stuff & Return to file ThisFile
end repeat
Close File ThisFile
end mouseUp
-- part 17 (button)
-- low flags: 00
-- high flags: 0004
-- rect: left=286 top=289 right=338 bottom=343
-- title width / last selected line: 0
-- icon id / first selected line: 8538 / 8538
-- text alignment: 1
-- font id: 0
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: SuperFind: Chris Hostetter
----- HyperTalk script -----
on mouseUp
-- Super Find, by Chris Hostetter
-- Mac Help Co., 1800 East Market Street
-- Long Beach, CA 90805, (213) 428-7414
-- This script may be freely used in other stacks provided that:
-- 1. You keep it in its entirety
-- (you can use the (--) to turn any un-needed lines off)
-- 2. You notify the author (see above)
global LastButton, searchstring, LastField
get the selection
if it is not empty then put it into SearchString
if the optionKey is down then
put "This advanced search button allows you to enter information" && "you wish to find. It will take you to the card which has" && "the words (or the parts of the words) you enter (note: the" && "words don't have to be in the same order). You can then" && "hit the carriage return to repeat the search over and over." && "If you hold the option key down while clicking OK, you can" && "be more specific about finding information in 1. the last" && "background field you clicked in (not always supported), and 2." && "whether you wish to find whole words, partial words, or the" && "characters that you entered." into String
put the name of the target into ThisItem
HelpMsg2 String, ThisItem
exit mouseUp
end if
put the name of the target into ThisOne
set hilite of thisOne to true
put "Chars" into FindType
put empty into SearchLimit
ask "Find Word(s)? Hold option key for limits." with SearchString
set hilite of thisOne to false
if it is empty then
exit mouseUp
end if
put it into SearchString
if the OptionKey is down then
if LastField is not empty then
Answer "Search for information in what field?" with "Cancel" or LastField or "Any Field"
if it is "Cancel" Then
exit mouseUp
end if
if it is LastField then
put " in background field " & NumToChar(34) & it & NumToChar(34) into SearchLimit
else
put "" into SearchLimit
end if
end if
Answer "Find " & FindType & " '" & Searchstring & "'" with "Begins With" or "Full Word" or "These Chars"
if it is "Begins with" then put empty into FindType
if it is "Full Word" then put "Word" into FindType
if it is "These Chars" then put "Chars" into FindType
end if
set loc of message box to 20,-50
put "Find" && FindType && Quote & SearchString & Quote & SearchLimit into message box
hide message box
set loc of message box to 20,300
do message box
if the result is "Not Found" then
beep
answer FindType && "'" & SearchString & "' not found. Search more?" with "No" or "Yes"
if it is "Yes" then click at the loc of the name of the target
end if
end mouseUp
-- part 18 (button)
-- low flags: 00
-- high flags: A004
-- rect: left=40 top=289 right=338 bottom=98
-- title width / last selected line: 0
-- icon id / first selected line: 15972 / 15972
-- text alignment: 1
-- font id: 0
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: Clear YTD
----- HyperTalk script -----
on mouseUp
Global GivingDate, ShortGivingDate, ExitFlag, DatePhrase
if the optionKey is down then
put "Clear the year to date of the sub accounts (for the bank" && "accounts.) (To clear for the DataBase, go to the Income Database.)" && " You can clear just the balance fields, or just the transaction" && "fields (leaving the balance still intact), or clear both." into String
put the name of the target into ThisItem
HelpMsg1 String, ThisItem
exit mouseUp
end if
Answer "Do you wish to ERASE (ALL) of the sub-account totals? This will set all totals to zero!" with "ERASE" or "Ooops - NO"
if it is "Erase" then
answer "Have you printed out any needed information? This is your last chance to print any information before it will be erased." with "ERASE" or "Cancel"
if it is "Cancel" then exit mouseUp
answer "Clear Year To Date of 'Transactions' or 'Balances'?" with "Transactions" or "Balances" or "Both"
put it into whichtype
if whichType is "Both" then put 3 into WhichType
if whichtype is "Balances" then put 1 into WhichType
if whichtype is "Transactions" then put 2 into WhichType
put "Would you like the new recording date to be " into DatePhrase
put False into ExitFlag
send "DoDate" to background
if ExitFlag then exit mouseUp
set the name of background button id 9 to GivingDate
set numberformat to 0.00
go to last card of this background
put the id of this card into FlagCardID
if WhichType is 1 or WhichType is 3 then
put empty into background field "Sub Total"
end if
if WhichType is 2 or WhichType is 3 then
put empty into background field "Sub Amount"
end if
go to first card of this background
repeat until the ID of this card is FlagCardID
set lockscreen to false
if WhichType is 1 or WhichType is 3 then
put empty into background field "Sub Total"
end if
if WhichType is 2 or WhichType is 3 then
put empty into background field "Sub Amount"
end if
go to next card of this background
end repeat
end if
go to card "Rpt."
end mouseUp
-- part 19 (button)
-- low flags: 00
-- high flags: A004
-- rect: left=224 top=289 right=339 bottom=281
-- title width / last selected line: 0
-- icon id / first selected line: 20186 / 20186
-- text alignment: 1
-- font id: 0
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: Sort
----- HyperTalk script -----
on mouseUp
global LastField, LastLine
if LastLine is 0 then put 1 into LastLine
answer "Sort all cards of this stack according to:" with "As Entered" or "Last Entered" or "Other"
push this card
if it is "Last Entered" then
sort descending by line 2 of background field "Creation Date"
go to Last Card
end if
if it is "As Entered" then sort by line 2 of background field "Creation Date"
if it is "Other" then
put LastField into AskField
answer "Sort all cards of this stack according to:" with AskField or "CANCEL"